<template>
  <div class='new-album-content'>
    <div class="main-tab-content">
      <div class='fl main-tab-title'>
        <a href="http://blog.csdn.net/superbirds" title="新碟上架">新碟上架</a>
      </div>
    </div>
    <div class='album-content mt20'>
      <el-carousel :autoplay='false' trigger="click" height="200px">
        <el-carousel-item class='carousel' v-for="item in subAlbumLists" :key="item.id">
          <ul class='wrap'>
            <li class='fl' v-for="data in item" :key="data.id">
              <div class='u-cover posi-rel' @click='routerPlaylist(data.albumId)'>
                <img class='album-img posi-ab' :src=data.coverUrl alt="">
                <a href="javascript:;" class='u-cover-mask posi-ab'></a>
              </div>
              <p><a href="javascript:;" class='fs12'>{{ data.albumName }}</a></p>
              <p><a href="javascript:;" class='fs12 fcgray'>{{ data.artistName }}</a></p>
            </li>
          </ul>
        </el-carousel-item>
      </el-carousel>
    </div>
  </div>
</template>

<script>
import utils from '../utils/common'
export default {
  name: 'newAlbum',
  data() {
    return {
      albumList: [],
      subAlbumLists: []
    }
  },
  methods: {
    async _getAlbumList() {
      let res = await this.$api.getAlbumList()
      this.albumList = res.data.products
      this.subAlbumLists = utils.group(this.albumList, this.albumList.length / 2)
      
    },
    routerPlaylist(row){
      console.log('row:', row)
      this.$router.push({path:'/album', query:{ id:row}})
    }
  },
  mounted() {
    this._getAlbumList()
  }
}
</script>

<style lang='less' scoped>
  .new-album-content {
    height: auto;
    .album-content {
      height: 200px;
      border: 1px solid #d3d3d3;
      .wrap {
        width: 870px;
        margin: 30px auto 0;
        height: 140px;
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        li {
          width: 120px;
          height: 100%;
          margin-right: 30px;
          &:last-child {
            margin-right: 0;
          }
          a {
            width: 100%;
            height: 100%;
          }
          .u-cover {
            width: 100px;
            height: 100px;
            .album-img {
              width: 100%;
              height: 100%;
            }
            .u-cover-mask {
                width: 118px;
                height: 100px;
                top: 0;
                left: 0;
                background: url('../assets/coverall.png');
                background-position: 0px -570px;
            }
          }
          p {
            width: 100%;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
          }
        }
      }
    }
  }
  
  .el-carousel__item h3 {
    color: #475669;
    font-size: 14px;
    opacity: 0.75;
    line-height: 150px;
    margin: 0;
  }
  .el-carousel__item {
    background-color: #f5f5f5;
  }
</style>
